<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>星级支部考核</title>
<%@ include file="/module/js.jsp"%>
	 <script type="text/javascript" src="${basePath}/js/jquery.Huploadify.js"></script>
    <link href="${basePath}/css/Huploadify.css" rel="stylesheet">
    <script type="text/javascript" src="${basePath}/js/raty/jquery.raty.js"></script>
    <link href="${basePath}/js/raty/jquery.raty.css" rel="stylesheet">
	<script type="text/javascript">
						$(document).ready(function() {
								// 去掉相同的option
								$("#khnd option").each(function() {
								   var getText = $(this).val();
								   if($("#khnd option:contains("+getText+")").length > 1){
								   		$("#khnd option:contains("+getText+"):gt(0)").remove();
								   }
								});
								
								//查询所有的活动信息
								$('#partyBranchStar').datagrid({
								   rowStyler: function(index,row){
								   },
								   onLoadSuccess : function(data) {//加载完毕后获取所有的checkbox遍历
										if (data.rows.length > 0) {
										}
									},
								});
								
								//条件查询
								$('#btnQuery').click(function() {
									$('#partyBranchStar').datagrid('load',{
										dZBMC: $('#dZBMC').val(),
										khnd: $('#khnd').val(),
										begintime: $("#begintime").val(),
										endtime: $("#endtime").val()
									});
								});
								
								//新增
								$('#btnAdd').click(function() {
									window.location.href = "${basePath}/partyBranchStar/preadd";
								});

								//删除
								$('#btnDelete').click(function() {
									               $("#idList").val("");
													var count = 0;
													var idList = new Array();
												    var sels = $("#partyBranchStar").datagrid("getSelections");
											    	for(var i in sels){
											    		idList.push(sels[i].khid);
											    		count++;
											    	}
													console.log(idList);
													if (count == 0) {
														layer.alert("您至少选择一条删除记录信息", {icon: 3});
														return false;
													}else{
														  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
															    $("#idList").val(idList);
															    document.demoForm.action = "${basePath}/partyBranchStar/delete";
																document.demoForm.submit();
														  },function(index){
																layer.close(index);
														  });
													}
								});
								
								
								$("#btnImport").click(function(){
											$('#importDiv').dialog('open');
								});
							
							     
								//数据下载
								$('#btnExport').on('click', function(){
								     layer.confirm("您确定要下载吗?", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
											document.demoForm.action = "${basePath}/partyBranchStar/export";
											document.demoForm.submit();
											layer.close(index);
					          		 });
								});
								
							 	$('#starBg').raty({
							 		readOnly : true,
							 		number : 10,
					                starOff : '${basePath}/js/raty/images/star-off.png',
					                starOn  : '${basePath}/js/raty/images/star-on.png',
					                score:3
					            });
							 	
							 	if($('#begintime').val() > $('#endtime').val()){
							 		layer.alert("开始时间不能晚于结束时间");
							 	};
							 	
					});//renturn documen
					
	            
			//通过格式化字段显示党支部名称和党支部书记
			function dzbmc(val,row,index){
				return "<a href='${basePath}/partyBranchStar/info?khid=" + row.khid + "'>" + row.partyBranch.dZBMC + "</a>";
			}
			function dzbsj(val,row,index){
				return row.partyBranch.dZBSJXM;
			}
			
			function stars(val,row,index){
				var _html = '';
				for(var i=1;i<=row.stars;i++){
					_html+='<img alt="'+i+'" src="${basePath}/js/raty/images/star-on.png" title="regular">';
				}
				return _html;
			}
			
			function formater(value, row, index) {
		          return "<a href='${basePath}/partyBranchStar/views?hkid=" + row.khid + "'>" + value + "</a>";
		    } 
	    //设置时间
		function formatDate(value){
	    	if(value!=null){
	    		var date=new Date(value);
				var y = date.getFullYear();
				var m = date.getMonth()+ 1;
				var d = date.getDate();
				var h= date.getHours();       //获取当前小时数(0-23)
				var mm= date.getMinutes();     //获取当前分钟数(0-59)
				var s= date.getSeconds();     //获取当前秒数(0-59)
				return y +'-'+(m <10?('0'+ m):m)+'-'+(d <10?('0'+ d):d)+' :'+(h <10?('0'+ h):h)+':'+(mm <10?('0'+ mm):mm)+':'+(s <10?('0'+ s):s);
	    	}else{
	    		return "";
	    	}
	    	
		}
	</script>
</head>
<body >
	<form action="#" name="demoForm" id="demoForm" method="post">
	<input type="hidden" name="idList" id="idList"/>
	
	
		<table cellpadding="1" cellspacing="1" border="0">
			<c:if test="${_login_user_type==2}">
			<tr>
				<td><input type="button" id="btnQuery" autocomplete="off"  value="查询"
					class="inputButton" /></td>
				<td>
				 <kl:permission permisstionList="${permisstionList}"
                    currentUser="${_login_console_user}"
                    currentCatalogId="<%=CatalogUtils.getCatalogId(\"ZHDJ_KHGL_XJZB\")%>" key="add"> 
				<input type="button" id="btnAdd" value="添 加" autocomplete="off" 
					class="inputButton" />
				</kl:permission>	
				</td>
				<td>
				 <kl:permission permisstionList="${permisstionList}"
                    currentUser="${_login_console_user}"
                    currentCatalogId="<%=CatalogUtils.getCatalogId(\"ZHDJ_KHGL_XJZB\")%>" key="delete">
				<input type="button" id="btnDelete" value="删除"
					class="inputButton" />
				 </kl:permission>
				</td>
			 	<td><input type="button" id="btnExport" value="导出"
					class="inputButton" /></td>
			</tr>
		  </c:if>	
		</table>
		<table cellpadding="1" cellspacing="1" >
			<tr>
				<td style="width: 15%">年度：</td>
				<td style="width: 30%">
					<select id="khnd" name="khnd" class="selectList2">
				  		<option value="">全部</option>
						<c:forEach items="${data}" var="data">
					   		<option value="${data.xnd}">${data.xnd}</option>
						</c:forEach>
					</select>
				</td>
				<td style="width: 15%">党支部名称：</td>
				<td style="width: 30%"><input type="text" id="dZBMC" name="dZBMC" value="" class="inputText2" /></td>
				
			</tr>
			<tr>
				<td style="width: 15%">评定日期：</td>
				<td style="width: auto;" colspan="3">
				   <input type="text" name="begintime" id="begintime"   autocomplete="off" 
					   class="Wdate inputText2"
					   onFocus="WdatePicker({dateFmt:'yyyy'})"/>&nbsp;到
				   <input type="text" name="endtime" id="endtime"   autocomplete="off" 
				   class="Wdate inputText2"
					   onFocus="WdatePicker({dateFmt:'yyyy'})"/> 
				</td>
			</tr>
		</table>
		<br/>
		<!-- 需要序号：增加 rownumbers:true-->
		<table id="partyBranchStar"   style="width: 100%;"
		data-options="pagination:true,collapsible:true,url:'${basePath}/partyBranchStar/listData',method:'post',remoteSort:true">
		<thead>
			<tr>
				<th data-options="field:'khid',checkbox:true,width:10,align:'center'"></th>
				<th data-options="field:'dzbid',sortable:true,nowrap:true,width:100,align:'center',hidden:'true',formatter:dzbmc">党支部id</th>
				<th data-options="field:'dZBMC',sortable:true,nowrap:true,width:100,align:'center',formatter:dzbmc">党支部名称</th>
				<th data-options="field:'dZBSJXM',nowrap:true,width:100,align:'center',sortable:true,formatter:dzbsj">党支部书记</th>
				<th data-options="field:'khnd',nowrap:true,width:100,align:'center',sortable:true">考核年度</th>
				<th data-options="field:'sbnzf',nowrap:true,width:200,align:'center',sortable:true">支部党员先锋指数上半年总分</th>
				<th data-options="field:'xbnzf',nowrap:true,width:200,align:'center',sortable:true">支部党员先锋指数下半年总分</th>
				<th data-options="field:'xbnzf',nowrap:true,width:200,align:'center',sortable:true">支部党员先锋指数全年平均值</th>
				<th data-options="field:'mzcpqk',nowrap:true,width:100,align:'center',sortable:true">民主测评情况</th>
				<th data-options="field:'zzwyhkhqk',nowrap:true,width:150,align:'center',sortable:true">总支委员会考核情况</th>
				<th data-options="field:'qtkhqk',nowrap:true,width:100,align:'center',sortable:true">其他考核情况</th>
				<th data-options="field:'stars',nowrap:true,width:200,align:'center',sortable:true,formatter:stars">星级</th>
			</tr>
		</thead>
	</table>
	</form>
</body>
</html>
